<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>使用tshark抓包分析http请求 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>使用tshark抓包分析http请求</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<p>&#160; &#160; &#160; &#160;默认我们的机器上是没有安装这个工具的。如果你的linux是CentOS那么就使用yum安装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum  install  -y  wireshark</div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160;也可以到<a href="http://www.wireshark.org" target="_blank" rel="external">官网</a>下载源码<br>具体安装方法，请<a href="http://www.qtasp.cn/wiresharkcharpt/buildingwireshark.html" target="_blank" rel="external">参考</a><br>以下，简单介绍这个抓包工具的应用</p>
<p>&#160; &#160; &#160; &#160;1. 以下的用法可以显示访问http请求的域名以及uri</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tshark -n -t a -R http.request -T fields -e <span class="string">"frame.time"</span> -e <span class="string">"ip.src"</span> -e <span class="string">"http.host"</span> -e <span class="string">"http.request.method"</span> -e <span class="string">"http.request.uri"</span></div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160;2. 以下可以抓取mysql的查询</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tshark -n -i eth1 -R <span class="string">'mysql.query'</span> -T fields -e <span class="string">"ip.src"</span> -e <span class="string">"mysql.query"</span></div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160;另外一种方法：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tshark -i eth1 port 3307  -d tcp.port==3307,mysql -z <span class="string">"proto,colinfo,mysql.query,mysql.query"</span></div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160; 3. 以下可以抓取指定类型的MySQL查询 </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tshark -n -i eth1 -R <span class="string">'mysql matches "SELECT|INSERT|DELETE|UPDATE"'</span> -T fields -e <span class="string">"ip.src"</span> -e <span class="string">"mysql.query"</span></div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160;4. 统计http的状态</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">tshark -n -q -z http,<span class="built_in">stat</span>, -z http,tree</div></pre></td></tr></table></figure>
<p>&#160; &#160; &#160; &#160;这个命令，直到你ctrl + c 才会显示出结果</p>
<p>&#160; &#160; &#160; &#160;5.  tshark 增加时间标签   </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">tshark  -t  ad</div><div class="line">tshark  -t  a</div></pre></td></tr></table></figure>
	

	
		<span class="different-posts"><a href="/2017/10/12/1. Linux 基础/47.使用tshark抓包分析http请求/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
